/*
 * comm.h
 *
 *  Created on: 25.10.2011
 *      Author: Moritz
 */

#ifndef COMM_H_
#define COMM_H_


#define COMM_COMMAND_TERM '\r'


#define Comm_Connect "Connect"
#define Comm_ConnectOK "ConnectOK"
#define Comm_SendLog "SendLog"
#define Comm_SendLogOK "SendLogOK"
#define Comm_Log "Log"   //Log n*{[Log_Level],[Log_Source],[TimeStamp],[Message];}\n
#define Comm_GetLog "GetLog"
#define Comm_GetLogOK "GetLogOK"
#define Comm_Unknown "Unknown Command"
#define Comm_CommandRegisterSize 40



#define CS_FLAG_ACTIVE 		1
#define CS_FLAG_CONNECTED 		2
#define CS_FLAG_READY			4
#define CS_FLAG_CMDSTART 		8
#define CS_FLAG_CMDCOMPLETE 	16
#define CS_FLAG_DATASTART		32
#define CS_FLAG_DATAEND		64

#define CS_FLAG_TXERROR		1024
#define CS_FLAG_RXERROR		2048


struct Commsrv_struct {
	char CommandRegister[Comm_CommandRegisterSize];
	int CommandRegisterIndex;

	int flags;

	Usart usart;
};

typedef struct Commsrv_struct * Commsrv;


int comm_init();
int comm_cycle();

void callback_serial(void);
void callback_bluetooth(void);



Commsrv getSerialSrv();
Commsrv getBluetoothSrv();

int Comm_getBefehl();  //Return 1(True) wenn Signal kahm sonst 0(false)

void Comm_sendBefehl(Commsrv srv, char* Message);


int Comm_sendBefehlData(Commsrv srv, char* Cmd, int (*dataProvider)(int line, char *content), int contentLineSize);

void Comm_Init();


#endif /* COMM_H_ */
